import javax.swing.JOptionPane;

public class HasWon extends Thread {
	private final Player winningPlayer;
	private final GameFrame frame;
	private final Game game;

	HasWon(Player player, Game game, GameFrame frame) {
		super();
		this.winningPlayer = player;
		this.game = game;
		this.frame = frame;
	}

	@Override
	public void run() {
		try {
			sleep(125L);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}

		int result = JOptionPane.showConfirmDialog(null,
				"Gratulation, " + (winningPlayer.getName()) + System.getProperty("line.separator") + System.getProperty("line.separator")
						+ "Noch ein Spielchen?", "Frage", JOptionPane.YES_NO_OPTION);

		if (result == JOptionPane.YES_OPTION) {
			game.restart();
		} else {
			frame.shutdown();
		}
	}
}
